package com.agnes.phone;

import android.Manifest;
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Toast;

import com.agnes.phone.other.PhoneIncomingrReceiver;
import com.agnes.phone.service.PhoneService;
import com.agnes.phone.reciver.PhoneReceiverPage;
import com.agnes.phone.service.PhoneServicePage;
import com.agnes.phone.listener.PhoneStateListenerPage;
import com.tbruyelle.rxpermissions2.RxPermissions;

import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

public class MainActivity extends AppCompatActivity {



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        RxPermissions permissions = new RxPermissions(this);
        Disposable subscribe = permissions.request(Manifest.permission.CALL_PHONE)
                .subscribe(aBoolean -> {
                    if (!aBoolean) {
                        Toast.makeText(MainActivity.this, "请开启电话权限", Toast.LENGTH_SHORT).show();
                    }
                });

    }



    public void startPhoneListener(View view) {
        startActivity(new Intent(this, PhoneStateListenerPage.class));

    }

    public void startPhoneReceiver(View view) {
        startActivity(new Intent(this, PhoneReceiverPage.class));
    }

    public void startPhoneService(View view) {
        startActivity(new Intent(this, PhoneServicePage.class));
    }
}
